<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="description" content="">
	<meta name="author" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
	<title>Potree Viewer</title>

	<link rel="stylesheet" type="text/css" href="../build/potree/potree.css">
	<link rel="stylesheet" type="text/css" href="../libs/jquery-ui/jquery-ui.min.css">
	<link rel="stylesheet" type="text/css" href="../libs/perfect-scrollbar/css/perfect-scrollbar.css">
	<link rel="stylesheet" type="text/css" href="../libs/openlayers3/ol.css">
	<link rel="stylesheet" type="text/css" href="../libs/spectrum/spectrum.css">
	<link rel="stylesheet" type="text/css" href="../libs/jstree/themes/mixed/style.css">
</head>

<body>
	<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
	<script src="../libs/spectrum/spectrum.js"></script>
	<script src="../libs/perfect-scrollbar/js/perfect-scrollbar.jquery.js"></script>
	<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
	<script src="../libs/three.js/build/three.min.js"></script>
	<script src="../libs/other/BinaryHeap.js"></script>
	<script src="../libs/tween/tween.min.js"></script>
	<script src="../libs/d3/d3.js"></script>
	<script src="../libs/proj4/proj4.js"></script>
	<script src="../libs/openlayers3/ol.js"></script>
	<script src="../libs/i18next/i18next.js"></script>
	<script src="../libs/jstree/jstree.js"></script>
	<script src="../build/potree/potree.js"></script>
	<script src="../libs/plasio/js/laslaz.js"></script>
	
	<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
	<!-- INCLUDE SETTINGS HERE -->
	
	<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
		<div id="potree_render_area"></div>
		<div id="potree_sidebar_container"> </div>
	</div>
	
	<script>
	
		window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
		
		viewer.setEDLEnabled(true);
		viewer.setFOV(60);
		viewer.setPointBudget(2*1000*1000);
		viewer.loadSettingsFromURL();

		viewer.setDescription('Streaming point clouds from an <a href="https://entwine.io/" target="_blank">Entwine</a> backend.');

		viewer.loadGUI(() => {
			viewer.setLanguage('en');
			$("#menu_appearance").next().show();
			$("#menu_scene").next().show();
			viewer.toggleSidebar();
		});

		var getQueryParam = function(name) {
			name = name.replace(/[\[\]]/g, "\\$&");
			var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
				results = regex.exec(window.location.href);
			if (!results || !results[2]) return null;
			return decodeURIComponent(results[2].replace(/\+/g, " "));
		}

		{
			var server = "greyhound://cache.greyhound.io/resource/";

			/* Some current public resources:
				autzen
				half-dome
				iowa
				iowa-bridge
				iowa-city
				lake-isabella
				lone-star
				nyc
				nz
				red-rocks
				sncf
				space-shuttle
				st-helens
				vanuatu-village
			*/
			
			var resource = "autzen";
			
			
			//
			// Some recommended configurations:
			//
			
			//var resource = "iowa-bridge";
			//viewer.setMaterial("Intensity");
			//viewer.setIntensityRange(0, 65536);
			//viewer.setIntensityBrightness(0.2);
			
			//var resource = "iowa-city";
			//viewer.setMaterial("Intensity");
			
			//var resource = "lake-isabella";
			//viewer.setMaterial("Intensity");
			//viewer.setIntensityGamma(0.5);
			
			//var resource = "space-shuttle";
			//viewer.setMaterial("Intensity");
			//viewer.setIntensityRange(0, 4500);
			//viewer.setIntensityGamma(1.5);
			
			
			

			if (getQueryParam("server")) {
				server = getQueryParam("server");
			}
			if (getQueryParam("resource")) {
				resource = getQueryParam("resource");
			}

			Potree.loadPointCloud(server + resource + "/", "autzen", (e) => {
				viewer.scene.addPointCloud(e.pointcloud);
				e.pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
				e.pointcloud.material.size = 0.6;

				viewer.fitToScreen(0.5);
			});
		}

	</script>


  </body>
</html>
